package com.druid;

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig;
import org.junit.jupiter.api.Test;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

public class PasswordGenerator {


    public static void main(String[] args)  {

        testEncryption();

    }

    //加密
    public static void testEncryption(){
        //加密工具
        StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
        //加密配置
        EnvironmentStringPBEConfig config = new EnvironmentStringPBEConfig();
        //加密算法，写死即可
        config.setAlgorithm("PBEWithMD5AndDES");
        //加密使用salt设置
        config.setPassword("management@2021");
        //应用配置
        encryptor.setConfig(config);
        //需要加密数据
        String plaintext="12345";
        //加密
        String encrypttext=encryptor.encrypt(plaintext);

        System.out.println(plaintext + " : " + encrypttext);
    }

    @Test
    public  void  passwordGen(){
        BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
        String encode = bCryptPasswordEncoder.encode("12345");
        System.out.println(encode);
    }

}
